package com.janwen.j2se.juc;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class CounterThread implements Runnable {

	Counter counter = new Counter();
	
	static final Log logger = LogFactory.getLog(CounterThread.class);
	@Override
	public void run() {
		counter.incrementCounter();
		logger.info("before: " + counter.getValue());
	/*	try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}*/
		logger.info("After: " + counter.getValue());
	}

	
	public static void main(String[] args) throws InterruptedException {
		
		CounterThread c1 = new CounterThread();
		Thread t1 = new Thread(c1);
		t1.start();
		t1.join();
		Thread t2 = new Thread(c1);
		t2.start();
		t2.join();
		//Thread.sleep(1000);
		Thread t3 = new Thread(c1);
		t3.start();
		t3.join();
	}
}
